package com.neuedu.ylbx.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.neuedu.ylbx.pojo.MedicalService;
import com.neuedu.ylbx.service.MedicalServiceService;
import com.neuedu.ylbx.utils.ResultVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version V1.0
 * @author: xianzhen
 * @date: 2025/7/9
 */


@RestController
@RequestMapping("/medicalService")
@Tag(name = "医疗服务控制器")
@CrossOrigin
public class MedicalServiceController {
    @Autowired
    MedicalServiceService medicalServiceService;

    @RequestMapping("/getMedicalService")
    @Operation(summary = "获取医疗服务列表")
    public ResultVo<List<MedicalService>> getMedicalService( ) throws Exception {
        return ResultVo.ok(medicalServiceService.list());
    }

    @RequestMapping("/addMedicalService")
    @Operation(summary = "添加医疗服务")
    public ResultVo addMedicalService(MedicalService medicalService) throws Exception {
        medicalServiceService.save(medicalService);
        return ResultVo.ok("添加成功");
    }

    @RequestMapping("/updateMedicalService")
    @Operation(summary = "更新医疗服务")
    public ResultVo updateMedicalService(MedicalService medicalService) throws Exception {
        UpdateWrapper<MedicalService> updateWrapper = new UpdateWrapper<MedicalService>();
        updateWrapper.eq("id",medicalService.getId());
        medicalServiceService.update(medicalService,updateWrapper);
        return ResultVo.ok("修改成功");
    }

    @RequestMapping("/deleteMedicalService")
    @Operation(summary = "删除医疗服务")
    public ResultVo deleteMedicalService(Integer id) throws Exception {
        medicalServiceService.removeById(id);
        return ResultVo.ok("删除成功");
    }
    @DeleteMapping("/deleteMedicalServices")
    @Operation(summary = "批量医疗服务")
    public ResultVo deleteMedicalServices(@RequestBody List<Long> Ids){
        medicalServiceService.removeByIds(Ids);  // MyBatis-Plus 批量删除方法
        return ResultVo.ok("批量删除成功");
    }


//    @RequestMapping("/updateMedicalService")
//    @Operation(summary = "更新医疗服务医嘱")
//    public ResultVo updateMedicalService(InpatientDiagnosis inpatientDiagnosis) throws Exception {
//        UpdateWrapper<InpatientDiagnosis> updateWrapper = new UpdateWrapper<InpatientDiagnosis>();
//        updateWrapper.eq("id",inpatientDiagnosis.getId());
//        inpatientDiagnosisService.update(inpatientDiagnosis,updateWrapper);
//        return ResultVo.ok("修改成功");
//    }
//
//    @RequestMapping("/deleteMedicalService")
//    @Operation(summary = "删除医疗服务医嘱")
//    public ResultVo deleteMedicalService(Integer id) throws Exception {
//        inpatientDiagnosisService.removeById(id);
//        return ResultVo.ok("删除成功");
//    }
}
